package cn.com.api.mapper.base;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cn.com.api.entity.ApiT_user_admin;

//DAO
public interface T_user_adminMapperBase {

	// 根据id查看
	@Select("SELECT * FROM t_user_admin  WHERE user_id = #{user_id}")
	public ApiT_user_admin findT_user_adminById(Integer user_id);

	// 查看数据集
	@Select("SELECT * FROM T_user_admin")
	public List<ApiT_user_admin> findT_user_admins();

	// 添加
	@Insert("INSERT INTO t_user_admin (user_name, true_name, email, password, add_time, login_count, last_login, last_ip, action_list, city_id, role_id, status, is_super,reserve_money) VALUES (#{user_name}, #{true_name}, #{email}, #{password}, #{add_time}, #{login_count}, #{last_login}, #{last_ip}, #{action_list}, #{city_id}, #{role_id}, #{status}, #{is_super},#{reserve_money})")
	@Options(useGeneratedKeys = true, keyProperty = "user_id")
	public int insertT_user_admin(ApiT_user_admin t_user_admin);

	// 修改
	@Update("UPDATE t_user_admin SET user_name = #{user_name}, true_name = #{true_name}, email = #{email}, password = #{password}, add_time = #{add_time}, login_count = #{login_count}, last_login = #{last_login}, last_ip = #{last_ip}, action_list = #{action_list}, city_id = #{city_id}, role_id = #{role_id}, status = #{status}, is_super = #{is_super},reserve_money = #{reserve_money} WHERE user_id = #{user_id}")
	public int updateT_user_admin(ApiT_user_admin t_user_admin);

	// 删除
	@Delete("DELETE FROM t_user_admin  WHERE user_id = #{user_id}")
	public int deleteT_user_admin(Integer user_id);

	// Foreign keys revelant

	// 删除根据City_id
	@Delete("DELETE FROM t_user_admin  WHERE city_id = #{city_id}")
	public int T_user_adminDeleteByCity_id(String city_id);

	// 获取根据City_id
	@Select("SELECT user_id, user_name, true_name, email, password, add_time, login_count, last_login, last_ip, action_list, city_id, role_id, status, is_super FROM t_user_admin  WHERE city_id = #{city_id}")
	public List<ApiT_user_admin> findT_user_adminsByCity_id(String city_id);

	// 删除根据Role_id
	@Delete("DELETE FROM t_user_admin  WHERE role_id = #{role_id}")
	public int T_user_adminDeleteByRole_id(String role_id);

	// 获取根据Role_id
	@Select("SELECT * FROM t_user_admin  WHERE role_id = #{role_id}")
	public List<ApiT_user_admin> findT_user_adminsByRole_id(String role_id);

	// region Indexs revelant

	// 获取根据user_name
	@Select("SELECT * FROM t_user_admin  WHERE user_name = #{user_name}")
	public List<ApiT_user_admin> findT_user_adminsByUser_name(String user_name);

}
